/**
 * 页面缓存
 */
export default {
  state: {
    keepPages: []
  },
  mutations: {
    // 添加缓存页
    ADD_THE_PAGE(state, status) {
      const index = state.keepPages.findIndex(item => item === status)
      if (index === -1) {
        state.keepPages.push(status)
        state.keepPages = state.keepPages.filter(item => true)
      }
    },
    // 移除某一个缓存页
    REMOVE_THE_PAGE(state, status) {
      const index = state.keepPages.findIndex(item => (status && item.toLowerCase() === status.toLowerCase()))
      if (index > -1) {
        state.keepPages.splice(index, 1)
        state.keepPages = state.keepPages.filter(item => true)
      }
    },
    // 缓存页清空
    REMOVE_ALL_PAGE(state) {
      state.keepPages = []
    }
  }
}
